﻿<controlBase:ControlBase xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                         xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
                         xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                         xmlns:controlBase="clr-namespace:Rio.Framework.Pages"
                         xmlns:Rio_Framework_Pages_Controls="clr-namespace:Rio.Framework.Pages.Controls"
                         xmlns:Rio_Framework_Pages_Workflow="clr-namespace:Rio.Framework.Pages.Workflow"
                         xmlns:CriteriaControls="clr-namespace:Rio.Framework.Pages.CriteriaControls"
                         xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                         xmlns:mvvmLightCommand="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL4"
                         xmlns:sys="clr-namespace:System;assembly=mscorlib"
                         xmlns:criterias="clr-namespace:Rio.Framework.Pages.CriteriaControls"
                         x:Class="Rio.Framework.Pages.Controls.FolderPage"
                         mc:Ignorable="d"
                         d:DesignHeight="768"
                         d:DesignWidth="1024"
                         DataContext="{Binding RelativeSource={RelativeSource Self}}">

    <controlBase:ControlBase.Resources>
        <Rio_Framework_Pages_Controls:ManageWorkflowToolBarVisibility x:Key="ManageWorkflowToolBarVisibility" />
        <Rio_Framework_Pages_Controls:DocumentNameToOutlookBarItem x:Key="DocumentNameToOutlookBarItem" />

        <Style x:Key="TextBlockStyle"
               TargetType="TextBlock">
            <Setter Property="Margin"
                    Value="5,5,5,0" />
            <Setter Property="HorizontalAlignment"
                    Value="Stretch" />
            <Setter Property="TextWrapping"
                    Value="Wrap" />
        </Style>

    </controlBase:ControlBase.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <telerik:RadOutlookBar x:Name="radOutlookBar"
                               HorizontalAlignment="Stretch"
                               MinimizedButtonContent="{Binding SelectedItem.Header, ElementName=radOutlookBar, Mode=TwoWay}"
                               Grid.RowSpan="3"
                               Width="300"
                               SelectedIndex="1"
                               IsContentPreserved="True"
                               MinimizedAreaVisibility="Collapsed">
            <telerik:RadOutlookBarItem Name="indexBarItem"
                                       Header="Index"
                                       HorizontalAlignment="Stretch"
                                       Icon="/Rio.Framework.Pages;component/Assets/Images/indexBig.png"
                                       SmallIcon="/Rio.Framework.Pages;component/Assets/Images/indexSmall.png">
                <Grid Margin="5">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <StackPanel Grid.Row="0"
                                HorizontalAlignment="Stretch">
                        <TextBlock x:Name="labelOrganization"
                                   Style="{StaticResource TextBlockStyle}" />
                        <StackPanel Orientation="Horizontal"
                                    HorizontalAlignment="Stretch"
                                    VerticalAlignment="Stretch">
                            <Image x:Name="imageEntity"
                                   Width="32"
                                   Height="32"
                                   Margin="5,0,0,0"
                                   Source="../Assets/Images/Entity.png" />
                            <TextBlock x:Name="textBlockOrganization"
                                       Margin="5,5,5,0"
                                       HorizontalAlignment="Stretch"
                                       FontWeight="Bold"
                                       Text="{Binding CurrentOrganization.Name, NotifyOnValidationError=False}" />
                        </StackPanel>
                        <TextBlock x:Name="labelFolderType"
                                   Style="{StaticResource TextBlockStyle}" />
                        <StackPanel Orientation="Horizontal"
                                    Margin="0,0,0,5"
                                    HorizontalAlignment="Stretch"
                                    VerticalAlignment="Stretch">
                            <Image x:Name="imageFolderType"
                                   Width="32"
                                   Height="32"
                                   Margin="5,0,0,0"
                                   Source="../Assets/Images/Folder.png" />
                            <TextBlock x:Name="textBlockFolderType"
                                       Margin="5,5,5,0"
                                       HorizontalAlignment="Stretch"
                                       FontWeight="Bold"
                                       Text="{Binding CurrentFolderType.Label, NotifyOnValidationError=False}" />
                        </StackPanel>
                    </StackPanel>
                    <toolkit:DockPanel Grid.Row="1">
                        <ScrollViewer x:Name="indexScrollViewer"
                                      toolkit:DockPanel.Dock="Top"
                                      VerticalAlignment="Stretch"
                                      VerticalContentAlignment="Stretch"
                                      VerticalScrollBarVisibility="Auto"
                                      BorderThickness="0">
                            <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                <ContentControl x:Name="indexContentControl"
                                                IsEnabled="False">
                                    <CriteriaControls:StackIndexControl x:Name="StackIndex"
                                                                        IsSearchMode="False"
                                                                        CurrentOrganization="{Binding CurrentOrganization, Mode=TwoWay}"
                                                                        CurrentFolderType="{Binding CurrentFolderType, Mode=TwoWay}"
                                                                        CurrentFolder="{Binding CurrentFolder, Mode=TwoWay}"
                                                                        HorizontalAlignment="Stretch"
                                                                        VerticalAlignment="Stretch" />
                                </ContentControl>

                                <StackPanel Orientation="Horizontal"
                                        HorizontalAlignment="Right"
                                        toolkit:DockPanel.Dock="Bottom"
                                        Margin="10,20,10,5">
                                    <telerik:RadButton x:Name="buttonUpdateIndex"
                                                   VerticalAlignment="Bottom"
                                                   HorizontalAlignment="Right"
                                                   Click="buttonUpdateIndex_Click" />
                                    <telerik:RadButton x:Name="buttonCancelUpdateIndex"
                                                   Margin="5,0,5,0"
                                                   VerticalAlignment="Bottom"
                                                   HorizontalAlignment="Right"
                                                   Click="ButtonCancelUpdateIndexClick"
                                                   Visibility="Collapsed" />
                                </StackPanel>
                            </StackPanel>
                        </ScrollViewer>

                    </toolkit:DockPanel>
                </Grid>
            </telerik:RadOutlookBarItem>
            <telerik:RadOutlookBarItem Name="itemsBarItem"
                                       Header="Classement"
                                       HorizontalAlignment="Stretch"
                                       Icon="/Rio.Framework.Pages;component/Assets/Images/itemsBig.png"
                                       SmallIcon="/Rio.Framework.Pages;component/Assets/Images/itemsSmall.png">
                <Grid Margin="5">
                    <toolkit:DockPanel>

                            <ScrollViewer x:Name="itemsScrollViewer"
                                      toolkit:DockPanel.Dock="Top"
                                      VerticalAlignment="Stretch"
                                      VerticalContentAlignment="Stretch"
                                      VerticalScrollBarVisibility="Auto"
                                      BorderThickness="0">
                                <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                    
                                    <TextBlock x:Name="labelClassement"
                                            TextWrapping="Wrap"
                                            FontWeight="Bold" />

                                    <criterias:ItemTreeview x:Name="TreeViewControlItems"
                                                        IsSearchMode="True"
                                                        VerticalAlignment="Stretch"
                                                        VerticalContentAlignment="Stretch"
                                                        ItemChanged="TreeViewControlItems_ItemChanged"
                                                        ItemDblClicked="TreeViewControlItems_ItemDblClicked" />

                                    <telerik:RadButton x:Name="buttonUpdateDocumentItem"
                                                   toolkit:DockPanel.Dock="Bottom"
                                                   Width="135"
                                                   Margin="10,20,10,5"
                                                   VerticalAlignment="Bottom"
                                                   HorizontalAlignment="Right"
                                                   Click="buttonUpdateDocumentItem_Click" />
                                    <telerik:RadButton x:Name="buttonRestoreDocuments"
                                                   toolkit:DockPanel.Dock="Bottom"
                                                   Width="135"
                                                   Margin="10,20,10,5"
                                                   VerticalAlignment="Bottom"
                                                   HorizontalAlignment="Right"
                                                   Visibility="Collapsed"
                                                   Click="ButtonRestoreDocumentsClick" />
                            </StackPanel>
                        </ScrollViewer>

                    </toolkit:DockPanel>
                </Grid>
            </telerik:RadOutlookBarItem>
            <telerik:RadOutlookBarItem Name="folderBarItem"
                                       Header="Dossier"
                                       HorizontalAlignment="Stretch"
                                       Icon="/Rio.Framework.Pages;component/Assets/Images/folderBig.png"
                                       SmallIcon="/Rio.Framework.Pages;component/Assets/Images/folderSmall.png">
                <ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Auto"
                              BorderThickness="0"
                              Margin="5">
                    <StackPanel>
                        <telerik:RadButton x:Name="ManageFolderRightButton"
                                           Click="ManageFolderRightClick"
                                           Margin="0"
                                           Height="26">
                            <StackPanel Orientation="Horizontal">
                                <Image Source="../Assets/Images/lock.png"
                                       Width="24"
                                       Height="24" />
                                <TextBlock x:Name="ManageFolderRightButtonText"
                                           VerticalAlignment="Center"
                                           HorizontalAlignment="Stretch"
                                           Margin="5,0,0,0" />
                            </StackPanel>
                        </telerik:RadButton>
                        <telerik:RadButton Height="26"
                                           Margin="0,5,0,0"
                                           Command="{Binding OpenCommentWindowCommand, Mode=TwoWay}">

                            <telerik:RadButton.CommandParameter>
                                <sys:Boolean>False</sys:Boolean>
                            </telerik:RadButton.CommandParameter>
                            <StackPanel Orientation="Horizontal">
                                <Image x:Name="FolderCommentImg"
                                       Source="../Assets/Images/Comment.png"
                                       Width="24"
                                       Height="24" />
                                <TextBlock x:Name="labelFolderComment"
                                           VerticalAlignment="Center"
                                           HorizontalAlignment="Stretch"
                                           Margin="5,0,0,0" />
                            </StackPanel>

                        </telerik:RadButton>
                        <telerik:RadButton Height="26"
                                           Margin="0,5,0,0"
                                           Command="{Binding OpenHistoricWindowCommand, Mode=TwoWay}">
                            <StackPanel Orientation="Horizontal">
                                <Image Source="/Rio.Framework.Pages;component/Assets/Images/history_expander.png"
                                       d:LayoutOverrides="Width" />
                                <TextBlock Name="folderHistoricLabel"
                                           VerticalAlignment="Center"
                                           HorizontalAlignment="Stretch"
                                           Text="Historiques du dossier"
                                           Margin="5,0,0,0"
                                           FontWeight="Normal" />
                            </StackPanel>
                        </telerik:RadButton>
                    </StackPanel>
                </ScrollViewer>
            </telerik:RadOutlookBarItem>
            <telerik:RadOutlookBarItem x:Name="documentBarItem"
                                       Header="{Binding CurrentDocument, Converter={StaticResource DocumentNameToOutlookBarItem}, Mode=TwoWay}"
                                       ToolTipService.ToolTip="{Binding CurrentDocument.OriginalNameFile, Mode=TwoWay}"
                                       HorizontalAlignment="Stretch"
                                       Icon="/Rio.Framework.Pages;component/Assets/Images/documentBig.png"
                                       SmallIcon="/Rio.Framework.Pages;component/Assets/Images/documentSmall.png"
                                       Background="{Binding RadOutlookBarDocumentItemColorBackground, Mode=TwoWay}">

                <ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Auto"
                              BorderThickness="0"
                              Margin="5">
                    <StackPanel Orientation="Vertical"
                        VerticalAlignment="Stretch" 
                        HorizontalAlignment="Stretch">
                        <TextBlock Name="documentPropertiesLabel"
                            TextWrapping="Wrap"
                            Text="Propriétés"
                            FontWeight="Bold"
                            FontStyle="Italic" />
                        <Path Data="M108,299 L200.34717,299"
                        Fill="#FFF4F4F5"
                        Height="1"
                        Stretch="Fill"
                        Stroke="Black"
                        UseLayoutRounding="False"
                        Margin="5,5,5,0" />
                        <Rio_Framework_Pages_Controls:DocumentInformations x:Name="DocumentInfo"
                                                                    CurrentVersion="{Binding SelectedVersion, ElementName=VersionInfo, Mode=OneWay}"
                                                                    CurrentDocument="{Binding CurrentDocument, Mode=TwoWay}"
                                                                    d:LayoutOverrides="Width"
                                                                    Margin="0">

                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="DocumentUpdating">
                                    <mvvmLightCommand:EventToCommand Command="{Binding DocumentUpdatingCommand}"
                                                                PassEventArgsToCommand="True" />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>

                        </Rio_Framework_Pages_Controls:DocumentInformations>
                        <TextBlock Name="versionningLabel"
                            TextWrapping="Wrap"
                            Text="Versionning"
                            FontWeight="Bold"
                            FontStyle="Italic"
                            Margin="0,15,0,0" />
                        <Path Data="M108,299 L200.34717,299"
                        Fill="#FFF4F4F5"
                        Height="1"
                        Stretch="Fill"
                        Stroke="Black"
                        UseLayoutRounding="False"
                        Margin="5,5,5,0" />
                        <Rio_Framework_Pages_Controls:VersionInformations x:Name="VersionInfo"
                                                                    SelectedVersion="{Binding CurrentSelectedVersion, Mode=TwoWay}"
                                                                    CurrentDocument="{Binding CurrentDocument, Mode=TwoWay}"
                                                                    Margin="0">

                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="MakeToMajor">
                                    <mvvmLightCommand:EventToCommand Command="{Binding MakeToMajorCommand}"
                                                                PassEventArgsToCommand="True" />
                                </i:EventTrigger>

                                <i:EventTrigger EventName="AddVersion">
                                    <mvvmLightCommand:EventToCommand Command="{Binding AddVersionCommand}"
                                                                PassEventArgsToCommand="True" />
                                </i:EventTrigger>

                                <i:EventTrigger EventName="CheckOut">
                                    <mvvmLightCommand:EventToCommand Command="{Binding CheckOutCommand}"
                                                                PassEventArgsToCommand="True" />
                                </i:EventTrigger>

                                <i:EventTrigger EventName="VersionSelected">
                                    <mvvmLightCommand:EventToCommand Command="{Binding VersionSelectedCommand}"
                                                                PassEventArgsToCommand="True" />
                                </i:EventTrigger>

                            </i:Interaction.Triggers>

                        </Rio_Framework_Pages_Controls:VersionInformations>
                    </StackPanel>
                </ScrollViewer>
            </telerik:RadOutlookBarItem>
                
        </telerik:RadOutlookBar>
        <Grid x:Name="LeftContentPlaceHolder"
              Grid.RowSpan="3"
              Background="White"
              Visibility="Collapsed">
            <!-- DO NOT REMOVE THIS GRID : IT IS USED BY THE WORKFLOW TO DISPLAY INDEX PANEL -->
        </Grid>
        <Rio_Framework_Pages_Workflow:WorkflowToolBar x:Name="workflowToolbar"
                                                      Grid.Column="1"
                                                      Height="35"
                                                      HorizontalAlignment="Stretch"
                                                      WorkflowManager="{Binding WorkflowManager, Mode=TwoWay}"
                                                      Visibility="{Binding WorkflowManager, Converter={StaticResource ManageWorkflowToolBarVisibility}, Mode=TwoWay}"
                                                      d:LayoutOverrides="Height" />
        <Grid x:Name="ViewerControlPanel"
              Grid.Column="1"
              Grid.Row="1" />
    </Grid>
</controlBase:ControlBase>